-- env.setErrorMessageBoxEnabled(true)
local escortfighter = SPAWN:New("RED F-16C"):InitRepeat()

IRONBLOOD_BOMBER = SPAWN:New("IRONBLOOD Bomber"):InitRepeat()
    :OnSpawnGroup(function(group)
        local escortgroup
        if escortfighter:GetFirstAliveGroup() == nil then
            escortgroup = escortfighter:Spawn()
        else
            escortgroup = escortfighter:GetFirstAliveGroup()
        end
        
        local tempVec3 = POINT_VEC3:New(-700, 50, -150)
        local temptask = escortgroup:TaskEscort(group, tempVec3, nil, 15000, {"Air"})
        escortgroup:PushTask(temptask, 2)
        MessageToAll("====================\n格里芬战情通报:\n发现敌方轰炸机正在新罗西斯克机场活动\n====================",
            10, "格里芬战情通报")
    end)
    :InitRepeat()
    :InitLimit(2, 0)
    :SpawnScheduled(800, 0.3)
IRONBLOOD_BOMBER:SpawnScheduleStart()

AXIS_Tanks = {
    SPAWN:New("AXIS Tank 1th-1"):InitLimit(10, 0):SpawnScheduled(600, 0.15),
    SPAWN:New("AXIS Tank 1th-2"):InitLimit(10, 0):SpawnScheduled(600, 0.15),
    SPAWN:New("AXIS Tank 1th-3"):InitLimit(10, 0):SpawnScheduled(600, 0.15),
    SPAWN:New("AXIS Tank 1th-4"):InitLimit(10, 0):SpawnScheduled(600, 0.15)
}

for i, v in ipairs(AXIS_Tanks) do
    v:SpawnScheduleStart()
end

AXIS_Inf = SPAWN:New("AXIS Infantry 49th"):InitLimit(7, 0):SpawnScheduled(600, 0.3)
AXIS_Inf:SpawnScheduleStart()

IRONBLOOD_FIGHTER = SPAWN:New("IRONBLOOD Fighter-1"):InitRepeat()
    :OnSpawnGroup(function(group)
        local PatrolZone = ZONE:New("RED CAP")
        local AICapZone = AI_CAP_ZONE:New(PatrolZone, 4572, 10668, 450, 700, "BARO")
        local EngageZoneGroup = GROUP:FindByName("RED ENGAGEZONE")
        local EngageZone = ZONE_POLYGON:New("RED ENGAGEZONE", EngageZoneGroup)
        AICapZone:SetControllable(group)
        AICapZone:SetEngageZone(EngageZone)
        AICapZone:__Start(1)

        MessageToAll("====================\n格里芬战情通报:\n发现敌方战斗机正在矿水城机场活动\n====================",
            10, "格里芬战情通报")
    end)
    :InitLimit(2, 0)
    :SpawnScheduled(800, 0.3)

IRONBLOOD_FIGHTER:SpawnScheduleStart()
